<template>
  <div class="reportFormPage horizontal-border" v-if="show">
    <div class="report-dom horizontal">
      <el-row>
        <el-col :span="5" :offset="19">
          <div class="pageNumBox">
            <span>第</span>
            <span class="placeholder-min text-center">&nbsp;{{ form.page }}&nbsp;</span>
            <span>页，共</span>
            <span class="placeholder-min text-center">&nbsp;{{ form.totalPage }}&nbsp;</span>
            <span>页</span>
          </div>
        </el-col>
      </el-row>
      <div class="topTwoBox">
        <div class="centerName">{{ this.form.baobmc }}</div>
        <div class="codeText">
          <tr v-for="(item, index) in form.baobbhList">
            {{
              item
            }}
          </tr>
        </div>
      </div>
      <div class="threeTopBox">
        <div class="left-border">
          <div class="box-title">检测单位名称：</div>
          <div class>{{ form.jiancdwmc }}</div>
        </div>
        <div class="right-border">
          <span>记录编号：</span>
          <span class="placeholder">{{ form.jilbh }}</span>
        </div>
      </div>
      <!-- .........................1111111111111111111111111111111......................................................... -->
      <div class="table-border">
        <table height="160px" class="top-table">
          <tbody>
            <tr>
              <td height="30" align="center" width="15%">
                <span style="width: 90px; display: inline-block">工程名称</span>
              </td>
              <td width="35%" class="text-center">
                <span>{{ form.gongcmc }}</span>
              </td>
              <td align="center" width="15%">
                <span style="width: 90px; display: inline-block">工程部位/用途</span>
              </td>
              <td width="35%" class="text-center">
                <span>{{ form.gongcbwyt }}</span>
              </td>
            </tr>
            <tr>
              <td height="30" align="center">样品信息</td>
              <td class="specimen-border" colspan="3">
                <span>样品名称：</span>
                <span :class="{ placeholder: !form.yangpmc }">{{ form.yangpmc }}</span>
                <span>；样品编号：</span>
                <span :class="{ 'placeholder-long': !form.yangpbh }">{{ form.yangpbh }}</span>

                <span>；样品数量：</span>
                <span :class="{ placeholder: !form.yangpsl }">{{ form.yangpsl }}</span>
                <span>；样品状态：</span>
                <span :class="{ placeholder: !form.yangpzt }">{{ form.yangpzt }}</span>
                <span>；来样时间：</span>
                <span :class="{ placeholder: !form.yangpsj }">{{ form.yangpsj }}</span>
              </td>
            </tr>
            <tr>
              <td height="25" align="center" width="15%">
                <span style="width: 90px; display: inline-block">试验检测日期</span>
              </td>
               <!-- <td width="35%" class="text-center">{{ form.shiyjcrq }}</td> -->                                            
 <td width="35%" class="text-center">
      <el-input v-model="form.shiyjcrq" />
</td>
              <td align="center" width="15%">
                <span style="width: 90px; display: inline-block">试验条件</span>
              </td>
              <td v-if="isPdf" width="35%">
                温度：
                <span style="display: inline-block; width: 10%">{{ form.shiytjwd }}</span>
                ℃；湿度：
                <span style="display: inline-block; width: 10%">{{ form.shiytjsd }}</span
                >%RH
              </td>
              <td v-else width="35%">
                温度：
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.shiytjwd" class="height100" style="width: 15%" @blur="setHntqdhtfBgShiytj()" />℃；湿度：
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.shiytjsd" class="height100" style="width: 15%" @blur="setHntqdhtfBgShiytj()" />%RH
              </td>
            </tr>
            <tr>
              <td height="40" align="center" width="15%">
                <span style="width: 90px; display: inline-block">检测依据</span>
              </td>
              <td width="35%">
                <span v-if="isPdf">{{ form.jiancyj }}</span>
                <el-input v-else type="textarea" v-model="form.jiancyj" :rows="2" class="mark" @dblclick.native="showBsJiancyjView" readonly />
              </td>
              <td align="center" width="15%">
                <span style="width: 90px; display: inline-block">判定依据</span>
              </td>
              <td width="35%">
                <span v-if="isPdf">{{ form.pandyj }}</span>
                <el-input v-else type="textarea" v-model="form.pandyj" :rows="2" @dblclick.native="showBsJudgeBaseView" @focus="handleFocus('pandyj')" class="mark" />
              </td>
            </tr>
            <tr class="bottom-border">
              <td height="30" align="center">
                <div>主要仪器设备</div>
                <div>名称及编号</div>
              </td>
              <td colspan="3">
                <span v-if="isPdf">{{ form.zhuyyqsbmcjbh }}</span>
                <el-input v-else type="textarea" :rows="2" v-model="form.zhuyyqsbmcjbh" class="height100 width100 mark" @dblclick.native="showBsInstrumentView" readonly></el-input>
              </td>
            </tr>
          </tbody>
        </table>
        <!-- .................................22222222222222222222222222222222............................................... -->
        <table height="360px" class="middle-table">
          <tbody>
            <tr>
              <td colspan="4">龄期（d）</td>
              <td colspan="4">
                <el-input tabindex="200" v-model="form.detailList[0].lingq" @keydown.native="handleKeyDown($event, 0, 0)" :ref="'0_0'" />
              </td>
              <td colspan="4">设计强度等级</td>
              <td colspan="4">
                <el-input tabindex="200" v-model="form.detailList[0].qiangddj" @keydown.native="handleKeyDown($event, 0, 1)" :ref="'0_1'" />
              </td>
              <td colspan="4">混凝土类型</td>
              <td colspan="4">
                <el-input tabindex="200" v-model="form.detailList[0].leix" @keydown.native="handleKeyDown($event, 0, 2)" :ref="'0_2'" />
              </td>
            </tr>
            <tr>
              <td colspan="4">回弹仪检定证书证号</td>
              <td colspan="4">
                <el-input tabindex="200" v-model="form.detailList[0].zhengszh" @keydown.native="handleKeyDown($event, 1, 0)" :ref="'1_0'" />
              </td>
              <td colspan="4">回弹仪率定值</td>
              <td colspan="4">
                <el-input tabindex="200" v-model="form.detailList[0].lvdz" @keydown.native="handleKeyDown($event, 1, 1)" :ref="'1_1'" />
              </td>
              <td colspan="4">混凝土浇筑日期</td>
              <td colspan="4">
                <el-input tabindex="200" v-model="form.detailList[0].jiaozrq" @keydown.native="handleKeyDown($event, 1, 2)" :ref="'1_2'" />
              </td>
            </tr>
            <tr>
              <td rowspan="2" width="4%">
                测区
                <br />编号
              </td>
              <td colspan="1" rowspan="2" width="4%">
                测区
                <br />位置
              </td>
              <td colspan="16">实测回弹值Ri</td>
              <td rowspan="2" colspan="2">测区平均回弹值Rm</td>
              <td rowspan="2" width="6%">测试面状态</td>
              <td rowspan="2">
                检测
                <br />角度(°)
              </td>
              <td rowspan="2" colspan="2">碳化深度</td>
            </tr>
            <tr>
              <td>1</td>
              <td>2</td>
              <td>3</td>
              <td>4</td>
              <td>5</td>
              <td>6</td>
              <td>7</td>
              <td>8</td>
              <td>9</td>
              <td>10</td>
              <td>11</td>
              <td>12</td>
              <td>13</td>
              <td>14</td>
              <td>15</td>
              <td>16</td>
            </tr>
            <tr v-for="(item, index) in form.detailList" :key="index">
              <td>{{ item.bianh }}</td>
              <td>{{ item.weiz }}</td>
              <td>
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="item.shiczRi1"
                  @blur="calculateHuitzPjz(index)"
                  @keydown.native="handleKeyDown($event, index + 2, 0)"
                  :ref="`${index + 2}_0`"
                />
              </td>
              <td>
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="item.shiczRi2"
                  @blur="calculateHuitzPjz(index)"
                  @keydown.native="handleKeyDown($event, index + 2, 1)"
                  :ref="`${index + 2}_1`"
                />
              </td>
              <td>
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="item.shiczRi3"
                  @blur="calculateHuitzPjz(index)"
                  @keydown.native="handleKeyDown($event, index + 2, 2)"
                  :ref="`${index + 2}_2`"
                />
              </td>
              <td>
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="item.shiczRi4"
                  @blur="calculateHuitzPjz(index)"
                  @keydown.native="handleKeyDown($event, index + 2, 3)"
                  :ref="`${index + 2}_3`"
                />
              </td>
              <td>
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="item.shiczRi5"
                  @blur="calculateHuitzPjz(index)"
                  @keydown.native="handleKeyDown($event, index + 2, 4)"
                  :ref="`${index + 2}_4`"
                />
              </td>
              <td>
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="item.shiczRi6"
                  @blur="calculateHuitzPjz(index)"
                  @keydown.native="handleKeyDown($event, index + 2, 5)"
                  :ref="`${index + 2}_5`"
                />
              </td>
              <td>
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="item.shiczRi7"
                  @blur="calculateHuitzPjz(index)"
                  @keydown.native="handleKeyDown($event, index + 2, 6)"
                  :ref="`${index + 2}_6`"
                />
              </td>
              <td>
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="item.shiczRi8"
                  @blur="calculateHuitzPjz(index)"
                  @keydown.native="handleKeyDown($event, index + 2, 7)"
                  :ref="`${index + 2}_7`"
                />
              </td>
              <td>
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="item.shiczRi9"
                  @blur="calculateHuitzPjz(index)"
                  @keydown.native="handleKeyDown($event, index + 2, 8)"
                  :ref="`${index + 2}_8`"
                />
              </td>
              <td>
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="item.shiczRi10"
                  @blur="calculateHuitzPjz(index)"
                  @keydown.native="handleKeyDown($event, index + 2, 9)"
                  :ref="`${index + 2}_9`"
                />
              </td>
              <td>
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="item.shiczRi11"
                  @blur="calculateHuitzPjz(index)"
                  @keydown.native="handleKeyDown($event, index + 2, 10)"
                  :ref="`${index + 2}_10`"
                />
              </td>
              <td>
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="item.shiczRi12"
                  @blur="calculateHuitzPjz(index)"
                  @keydown.native="handleKeyDown($event, index + 2, 11)"
                  :ref="`${index + 2}_11`"
                />
              </td>
              <td>
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="item.shiczRi13"
                  @blur="calculateHuitzPjz(index)"
                  @keydown.native="handleKeyDown($event, index + 2, 12)"
                  :ref="`${index + 2}_12`"
                />
              </td>
              <td>
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="item.shiczRi14"
                  @blur="calculateHuitzPjz(index)"
                  @keydown.native="handleKeyDown($event, index + 2, 13)"
                  :ref="`${index + 2}_13`"
                />
              </td>
              <td>
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="item.shiczRi15"
                  @blur="calculateHuitzPjz(index)"
                  @keydown.native="handleKeyDown($event, index + 2, 14)"
                  :ref="`${index + 2}_14`"
                />
              </td>
              <td>
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="item.shiczRi16"
                  @blur="calculateHuitzPjz(index)"
                  @keydown.native="handleKeyDown($event, index + 2, 15)"
                  :ref="`${index + 2}_15`"
                />
              </td>
              <td colspan="2">
                <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="item.huitzPjz" disabled />
              </td>
              <td>
                <el-input tabindex="200" v-model="item.zhuangt" @keydown.native="handleKeyDown($event, index + 2, 16)" :ref="`${index + 2}_16`" />
              </td>
              <td>
                <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="item.jioad" @keydown.native="handleKeyDown($event, index + 2, 17)" :ref="`${index + 2}_17`" />
              </td>
              <td colspan="2">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="item.shend"
                  @blur="setHntqdhtfBgTanhsd()"
                  @keydown.native="handleKeyDown($event, index + 2, 18)"
                  :ref="`${index + 2}_18`"
                />
              </td>
            </tr>
          </tbody>
        </table>
        <!-- .....................................................33333333333333333................................................... -->
        <table height="30px" class="bottom-table">
          <tr>
            <td>
              <span v-if="isPdf" class="textarea-span">{{ form.fujsm }}</span>
              <el-input v-else type="textarea" :rows="2" v-model="form.fujsm" @focus="handleFocus('fujsm')" />
            </td>
          </tr>
        </table>
      </div>
      <!-- .................................44444444444............................................. -->
      <table height="22px" class="transparent">
        <tbody>
          <tr>
            <td width="10%" align="right">检测：</td>
            <td width="15%" align="left">
              <!-- {{this.form.jiancr}} -->
            </td>
            <td width="10%" align="right">记录：</td>
            <td width="15%" align="left">
              <!-- {{this.form.jilr}} -->
            </td>
            <td width="10%" align="right">复核：</td>
            <td align="left" width="15%">
              <!-- {{this.form.fuhr}} -->
            </td>
           
           <td width="10%">日期：</td>
            <td align="left" width="15%">
              <div style="display: inline-block; margin-left: 20px">年</div>
              <div style="display: inline-block; margin-left: 20px">月</div>
              <div style="display: inline-block ;margin-left: 20px">日</div>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
    <bs-instrument-view ref="bsInstrumentViewRef" @select="selectInstrument"></bs-instrument-view>
    <bs-jiancyj-view ref="bsJiancyjViewRef" @select="selectJiancyj" :syType="syType"></bs-jiancyj-view>
    <bs-judge-base-view ref="bsJudgeBaseViewRef" @select="selectJudge" :syType="syType"></bs-judge-base-view>
  </div>
</template>

<script>
import decimal from "@/utils/big-decimal";
import Bus from "@/utils/bus";
import { handleFocus, emptyConvert, calculateMeanvalue, handleKeyDown } from "@/views/reportForms/utils";
import { getHntjgHntqdhtfjlbBsInfo } from "@/api/report_hntjg/hntjg";
import BsInstrumentView from "@/views/dept/bsInstrument/BsInstrumentView.vue";
import BsJiancyjView from "@/views/sycs/bsJiancyj/BsJiancyjView.vue";
import BsJudgeBaseView from "@/views/sycs/bsJudgeBase/BsJudgeBaseView.vue";
import BaQjDetailView from "@/views/sycs/baQjDetail/BaQjDetailView.vue";
import TableLineLogChart from "@/views/reportForms/components/TableLineLogChart.vue";

export default {
  name: "hntqdhtfjlb",
  components: {
    BsInstrumentView,
    BsJiancyjView,
    BsJudgeBaseView,
    BaQjDetailView,
    TableLineLogChart
  },
  props: {
    excelId: {
      type: [String, Number],
      default: () => ""
    },
    syType: {
      type: [String, Number],
      default: () => ""
    },
    page: {
      type: Number,
      default: () => 0
    },
    isPdf: {
      type: Boolean,
      default: () => false
    },
    printEmpty: {
      type: Boolean,
      default: () => false
    }
  },
  data() {
    return {
      form: {
        detailList: [],
        baobbhList: []
      },
      show: false
    };
  },
  watch: {
    isPdf(newVal, oldVal) {
      this.form = { ...emptyConvert(this.form, newVal) };
    }
  },
  created() {
    this.init();
  },

  mounted() {
    // 传值碳化深度
    Bus.$on("setHntqdhtfjlbTanhsd", (data) => {
      data.forEach((item, index) => {
        this.form.detailList[index].shend = item;
      });
      this.setHntqdhtfBgTanhsd();
    });
  },
  beforeDestroy() {
    // 停止监听事件
    Bus.$off("setHntqdhtfjlbTanhsd");
  },
  methods: {
    // 根据报表id获取当前报表信息
    init() {
      this.show = false;
      getHntjgHntqdhtfjlbBsInfo(this.excelId || this.$defaultExcelId).then((response) => {
        this.form = response.data;
        this.setInitialValue();
        if (!this.form.detailList || this.form.detailList.length <= 0) {
          this.getDetailList();
        }
        this.show = true;
        if (!this.form.fujsm) {
          this.form.fujsm = "附加声明：";
        }
      });
    },
    // 设置初始值
    setInitialValue() {
      if (this.form) {
        this.form.baobmc = this.form.baobmc || "混凝土强度试验检测记录表（回弹法）";
        this.form.baobbh = this.form.baobbh || "JGLP02001b";
        this.$set(this.form, "baobbhList", []);
        this.form.baobbhList = ["JGLP02001b"];
      }
    },
    getDetailList() {
      this.$set(this.form, "detailList", []);
      const d1 = {
        detailId: undefined,
        excelId: this.excelId,
        sort: 1,
        bianh: "1",
        weiz: "01",
        shiczRi1: undefined,
        shiczRi2: undefined,
        shiczRi3: undefined,
        shiczRi4: undefined,
        shiczRi5: undefined,
        shiczRi6: undefined,
        shiczRi7: undefined,
        shiczRi8: undefined,
        shiczRi9: undefined,
        shiczRi10: undefined,
        shiczRi11: undefined,
        shiczRi12: undefined,
        shiczRi13: undefined,
        shiczRi14: undefined,
        shiczRi15: undefined,
        shiczRi16: undefined,
        huitzPjz: undefined,
        zhuangt: undefined,
        jioad: undefined,
        shend: undefined
      };
      const d2 = {
        detailId: undefined,
        excelId: this.excelId,
        sort: 2,
        bianh: "2",
        weiz: "02",
        shiczRi1: undefined,
        shiczRi2: undefined,
        shiczRi3: undefined,
        shiczRi4: undefined,
        shiczRi5: undefined,
        shiczRi6: undefined,
        shiczRi7: undefined,
        shiczRi8: undefined,
        shiczRi9: undefined,
        shiczRi10: undefined,
        shiczRi11: undefined,
        shiczRi12: undefined,
        shiczRi13: undefined,
        shiczRi14: undefined,
        shiczRi15: undefined,
        shiczRi16: undefined,
        huitzPjz: undefined,
        zhuangt: undefined,
        jioad: undefined,
        shend: undefined
      };
      const d3 = {
        detailId: undefined,
        excelId: this.excelId,
        sort: 3,
        bianh: "3",
        weiz: "03",
        shiczRi1: undefined,
        shiczRi2: undefined,
        shiczRi3: undefined,
        shiczRi4: undefined,
        shiczRi5: undefined,
        shiczRi6: undefined,
        shiczRi7: undefined,
        shiczRi8: undefined,
        shiczRi9: undefined,
        shiczRi10: undefined,
        shiczRi11: undefined,
        shiczRi12: undefined,
        shiczRi13: undefined,
        shiczRi14: undefined,
        shiczRi15: undefined,
        shiczRi16: undefined,
        huitzPjz: undefined,
        zhuangt: undefined,
        jioad: undefined,
        shend: undefined
      };
      const d4 = {
        detailId: undefined,
        excelId: this.excelId,
        sort: 4,
        bianh: "4",
        weiz: "04",
        shiczRi1: undefined,
        shiczRi2: undefined,
        shiczRi3: undefined,
        shiczRi4: undefined,
        shiczRi5: undefined,
        shiczRi6: undefined,
        shiczRi7: undefined,
        shiczRi8: undefined,
        shiczRi9: undefined,
        shiczRi10: undefined,
        shiczRi11: undefined,
        shiczRi12: undefined,
        shiczRi13: undefined,
        shiczRi14: undefined,
        shiczRi15: undefined,
        shiczRi16: undefined,
        huitzPjz: undefined,
        zhuangt: undefined,
        jioad: undefined,
        shend: undefined
      };
      const d5 = {
        detailId: undefined,
        excelId: this.excelId,
        sort: 5,
        bianh: "5",
        weiz: "05",
        shiczRi1: undefined,
        shiczRi2: undefined,
        shiczRi3: undefined,
        shiczRi4: undefined,
        shiczRi5: undefined,
        shiczRi6: undefined,
        shiczRi7: undefined,
        shiczRi8: undefined,
        shiczRi9: undefined,
        shiczRi10: undefined,
        shiczRi11: undefined,
        shiczRi12: undefined,
        shiczRi13: undefined,
        shiczRi14: undefined,
        shiczRi15: undefined,
        shiczRi16: undefined,
        huitzPjz: undefined,
        zhuangt: undefined,
        jioad: undefined,
        shend: undefined
      };
      const d6 = {
        detailId: undefined,
        excelId: this.excelId,
        sort: 6,
        bianh: "6",
        weiz: "06",
        shiczRi1: undefined,
        shiczRi2: undefined,
        shiczRi3: undefined,
        shiczRi4: undefined,
        shiczRi5: undefined,
        shiczRi6: undefined,
        shiczRi7: undefined,
        shiczRi8: undefined,
        shiczRi9: undefined,
        shiczRi10: undefined,
        shiczRi11: undefined,
        shiczRi12: undefined,
        shiczRi13: undefined,
        shiczRi14: undefined,
        shiczRi15: undefined,
        shiczRi16: undefined,
        huitzPjz: undefined,
        zhuangt: undefined,
        jioad: undefined,
        shend: undefined
      };
      const d7 = {
        detailId: undefined,
        excelId: this.excelId,
        sort: 7,
        bianh: "7",
        weiz: "07",
        shiczRi1: undefined,
        shiczRi2: undefined,
        shiczRi3: undefined,
        shiczRi4: undefined,
        shiczRi5: undefined,
        shiczRi6: undefined,
        shiczRi7: undefined,
        shiczRi8: undefined,
        shiczRi9: undefined,
        shiczRi10: undefined,
        shiczRi11: undefined,
        shiczRi12: undefined,
        shiczRi13: undefined,
        shiczRi14: undefined,
        shiczRi15: undefined,
        shiczRi16: undefined,
        huitzPjz: undefined,
        zhuangt: undefined,
        jioad: undefined,
        shend: undefined
      };
      const d8 = {
        detailId: undefined,
        excelId: this.excelId,
        sort: 8,
        bianh: "8",
        weiz: "08",
        shiczRi1: undefined,
        shiczRi2: undefined,
        shiczRi3: undefined,
        shiczRi4: undefined,
        shiczRi5: undefined,
        shiczRi6: undefined,
        shiczRi7: undefined,
        shiczRi8: undefined,
        shiczRi9: undefined,
        shiczRi10: undefined,
        shiczRi11: undefined,
        shiczRi12: undefined,
        shiczRi13: undefined,
        shiczRi14: undefined,
        shiczRi15: undefined,
        shiczRi16: undefined,
        huitzPjz: undefined,
        zhuangt: undefined,
        jioad: undefined,
        shend: undefined
      };
      const d9 = {
        detailId: undefined,
        excelId: this.excelId,
        sort: 9,
        bianh: "9",
        weiz: "09",
        shiczRi1: undefined,
        shiczRi2: undefined,
        shiczRi3: undefined,
        shiczRi4: undefined,
        shiczRi5: undefined,
        shiczRi6: undefined,
        shiczRi7: undefined,
        shiczRi8: undefined,
        shiczRi9: undefined,
        shiczRi10: undefined,
        shiczRi11: undefined,
        shiczRi12: undefined,
        shiczRi13: undefined,
        shiczRi14: undefined,
        shiczRi15: undefined,
        shiczRi16: undefined,
        huitzPjz: undefined,
        zhuangt: undefined,
        jioad: undefined,
        shend: undefined
      };
      const d10 = {
        detailId: undefined,
        excelId: this.excelId,
        sort: 10,
        bianh: "10",
        weiz: "10",
        shiczRi1: undefined,
        shiczRi2: undefined,
        shiczRi3: undefined,
        shiczRi4: undefined,
        shiczRi5: undefined,
        shiczRi6: undefined,
        shiczRi7: undefined,
        shiczRi8: undefined,
        shiczRi9: undefined,
        shiczRi10: undefined,
        shiczRi11: undefined,
        shiczRi12: undefined,
        shiczRi13: undefined,
        shiczRi14: undefined,
        shiczRi15: undefined,
        shiczRi16: undefined,
        huitzPjz: undefined,
        zhuangt: undefined,
        jioad: undefined,
        shend: undefined
      };
      this.form.detailList.push(d1);
      this.form.detailList.push(d2);
      this.form.detailList.push(d3);
      this.form.detailList.push(d4);
      this.form.detailList.push(d5);
      this.form.detailList.push(d6);
      this.form.detailList.push(d7);
      this.form.detailList.push(d8);
      this.form.detailList.push(d9);
      this.form.detailList.push(d10);
    },
    // 显示检测依据列表
    showBsJiancyjView() {
      this.$refs.bsJiancyjViewRef.init(this.form.jiancyjIds);
    },
    // 检测依据选择
    selectJiancyj(info) {
      this.form.jiancyj = info.label;
      this.form.jiancyjIds = info.ids;
      Bus.$emit("setHntqdhtfBgJiancyj", { jiancyj: this.form.jiancyj, jiancyjIds: this.form.jiancyjIds });
    },
    // 显示判定依据列表
    showBsJudgeBaseView() {
      this.$refs.bsJudgeBaseViewRef.init(this.form.pandyjIds);
    },
    // 判断依据选择
    selectJudge(info) {
       this.form.pandyjIds = info.ids;
      this.form.pandyj = info.label;
    },
    // 显示仪器列表
    showBsInstrumentView() {
      this.$refs.bsInstrumentViewRef.init(this.form.shebIds);
    },
    // 仪器选择
    selectInstrument(info) {
      this.form.zhuyyqsbmcjbh = info.label;
      this.form.shebIds = info.ids;
      Bus.$emit("setHntqdhtfBgZhuyyqsbmcjbh", { zhuyyqsbmcjbh: this.form.zhuyyqsbmcjbh, shebIds: this.form.shebIds });
    },
    // 计算平均回弹值
    calculateHuitzPjz(index) {
      let arr = [];
      for (let i = 1; i <= 16; i++) {
        const element = this.form.detailList[index]["shiczRi" + i];
        if (element) {
          arr.push(element);
        } else {
          this.form.detailList[index]["shiczRi" + i] = null;
        }
      }
      let huitzPjz = null;
      if (arr.length == 16) {
        // 先排序
        arr.sort((a, b) => {
          return a - b;
        });
        // 去掉前三后三 取平均值
        arr.splice(0, 3);
        arr.splice(arr.length - 3, arr.length - 1);

        huitzPjz = calculateMeanvalue(arr, 1);
      }
      this.form.detailList[index].huitzPjz = huitzPjz;
      this.setHntqdhtfBgHuitzPjz();
    },
    // 给报告传值
    setHntqdhtfBgHuitzPjz() {
      const arr = this.form.detailList.map((item) => item.huitzPjz);
      Bus.$emit("setHntqdhtfBgHuitzPjz", arr);
    },
    // 传值碳化深度
    setHntqdhtfBgTanhsd() {
      const arr = this.form.detailList.map((item) => item.shend);
      Bus.$emit("setHntqdhtfBgTanhsd", arr);
    },
    // 传值试验条件
    setHntqdhtfBgShiytj() {
      const info = {
        shiytjwd: this.form.shiytjwd,
        shiytjsd: this.form.shiytjsd
      };
      Bus.$emit("setHntqdhtfBgShiytj", info);
    },
    submitForm() {
      return this.form;
    },
    handleFocus(event) {
      handleFocus(event, this.page, this.form[event]);
    },
    handleKeyDown(event, rowIndex, colIndex) {
      const maxArr = [2, 2, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18];
      const ref = handleKeyDown(event, rowIndex, colIndex, maxArr);
      if (this.$refs[ref]?.length) {
        this.$refs[ref][0].focus();
      } else if (this.$refs[ref]) {
        this.$refs[ref].focus();
      }
    }
  }
};
</script>

<style scoped></style>
